﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SGArchiveSystem7xDB.Linq
{
    public  class T_SyspzDal
    {
        static SGArchiveSystem7xEntities conn;
        public static T_SysPZ Get_SysPZ(string type)
        {
            try
            {
                conn = new SGArchiveSystem7xEntities();
                return conn.T_SysPZ.Select(c => c).Where(c => c.PZ_TYPE == type).Single();
            }
            catch { return null; }
        }
        public static int Modify_SysPZ(T_SysPZ en)
        {
            try
            {
                conn = new SGArchiveSystem7xEntities();
                var query= conn.T_SysPZ.Select(c => c).Where(c => c.PZ_TYPE == en.PZ_TYPE);
                foreach (var nn in query)
                {
                    nn.PZ_VALUE = en.PZ_VALUE;
                }
                conn.SaveChanges();
                return en.PZ_ID;
            }
            catch { return -1; }
        }
        public static List<T_SysPZ> Get_SysPZ()
        {
            try
            {
                conn = new SGArchiveSystem7xEntities();
                return conn.T_SysPZ.Select(c => c).ToList();
            }
            catch { return null; }
        }
    }
}
